import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/entities/application/emergency/emergency_res_goods_detail_entity.dart';

EmergencyResGoodsDetailEntity $EmergencyResGoodsDetailEntityFromJson(Map<String, dynamic> json) {
  final EmergencyResGoodsDetailEntity emergencyResGoodsDetailEntity = EmergencyResGoodsDetailEntity();
  final String? companyCode = jsonConvert.convert<String>(json['companyCode']);
  if (companyCode != null) {
    emergencyResGoodsDetailEntity.companyCode = companyCode;
  }
  final String? createBy = jsonConvert.convert<String>(json['createBy']);
  if (createBy != null) {
    emergencyResGoodsDetailEntity.createBy = createBy;
  }
  final String? createById = jsonConvert.convert<String>(json['createById']);
  if (createById != null) {
    emergencyResGoodsDetailEntity.createById = createById;
  }
  final String? createDate = jsonConvert.convert<String>(json['createDate']);
  if (createDate != null) {
    emergencyResGoodsDetailEntity.createDate = createDate;
  }
  final String? deleted = jsonConvert.convert<String>(json['deleted']);
  if (deleted != null) {
    emergencyResGoodsDetailEntity.deleted = deleted;
  }
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    emergencyResGoodsDetailEntity.id = id;
  }
  final String? materialClassification = jsonConvert.convert<String>(json['materialClassification']);
  if (materialClassification != null) {
    emergencyResGoodsDetailEntity.materialClassification = materialClassification;
  }
  final String? materialClassificationName = jsonConvert.convert<String>(json['materialClassificationName']);
  if (materialClassificationName != null) {
    emergencyResGoodsDetailEntity.materialClassificationName = materialClassificationName;
  }
  final String? materialName = jsonConvert.convert<String>(json['materialName']);
  if (materialName != null) {
    emergencyResGoodsDetailEntity.materialName = materialName;
  }
  final String? materialPhotos = jsonConvert.convert<String>(json['materialPhotos']);
  if (materialPhotos != null) {
    emergencyResGoodsDetailEntity.materialPhotos = materialPhotos;
  }
  final String? materialPointId = jsonConvert.convert<String>(json['materialPointId']);
  if (materialPointId != null) {
    emergencyResGoodsDetailEntity.materialPointId = materialPointId;
  }
  final String? materialPointIdName = jsonConvert.convert<String>(json['materialPointIdName']);
  if (materialPointIdName != null) {
    emergencyResGoodsDetailEntity.materialPointIdName = materialPointIdName;
  }
  final String? purpose = jsonConvert.convert<String>(json['purpose']);
  if (purpose != null) {
    emergencyResGoodsDetailEntity.purpose = purpose;
  }
  final int? quantity = jsonConvert.convert<int>(json['quantity']);
  if (quantity != null) {
    emergencyResGoodsDetailEntity.quantity = quantity;
  }
  final String? transportationAndStorageRequirements = jsonConvert.convert<String>(json['transportationAndStorageRequirements']);
  if (transportationAndStorageRequirements != null) {
    emergencyResGoodsDetailEntity.transportationAndStorageRequirements = transportationAndStorageRequirements;
  }
  final String? updateBy = jsonConvert.convert<String>(json['updateBy']);
  if (updateBy != null) {
    emergencyResGoodsDetailEntity.updateBy = updateBy;
  }
  final String? updateById = jsonConvert.convert<String>(json['updateById']);
  if (updateById != null) {
    emergencyResGoodsDetailEntity.updateById = updateById;
  }
  final String? updateDate = jsonConvert.convert<String>(json['updateDate']);
  if (updateDate != null) {
    emergencyResGoodsDetailEntity.updateDate = updateDate;
  }
  final String? usageRecord = jsonConvert.convert<String>(json['usageRecord']);
  if (usageRecord != null) {
    emergencyResGoodsDetailEntity.usageRecord = usageRecord;
  }
  final List<EmergencyResGoodsDetailUsedRecordVos>? usedRecordVos = (json['usedRecordVos'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<EmergencyResGoodsDetailUsedRecordVos>(e) as EmergencyResGoodsDetailUsedRecordVos).toList();
  if (usedRecordVos != null) {
    emergencyResGoodsDetailEntity.usedRecordVos = usedRecordVos;
  }
  final String? validityPeriod = jsonConvert.convert<String>(json['validityPeriod']);
  if (validityPeriod != null) {
    emergencyResGoodsDetailEntity.validityPeriod = validityPeriod;
  }
  return emergencyResGoodsDetailEntity;
}

Map<String, dynamic> $EmergencyResGoodsDetailEntityToJson(EmergencyResGoodsDetailEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['companyCode'] = entity.companyCode;
  data['createBy'] = entity.createBy;
  data['createById'] = entity.createById;
  data['createDate'] = entity.createDate;
  data['deleted'] = entity.deleted;
  data['id'] = entity.id;
  data['materialClassification'] = entity.materialClassification;
  data['materialClassificationName'] = entity.materialClassificationName;
  data['materialName'] = entity.materialName;
  data['materialPhotos'] = entity.materialPhotos;
  data['materialPointId'] = entity.materialPointId;
  data['materialPointIdName'] = entity.materialPointIdName;
  data['purpose'] = entity.purpose;
  data['quantity'] = entity.quantity;
  data['transportationAndStorageRequirements'] = entity.transportationAndStorageRequirements;
  data['updateBy'] = entity.updateBy;
  data['updateById'] = entity.updateById;
  data['updateDate'] = entity.updateDate;
  data['usageRecord'] = entity.usageRecord;
  data['usedRecordVos'] = entity.usedRecordVos?.map((v) => v.toJson()).toList();
  data['validityPeriod'] = entity.validityPeriod;
  return data;
}

extension EmergencyResGoodsDetailEntityExtension on EmergencyResGoodsDetailEntity {
  EmergencyResGoodsDetailEntity copyWith({
    String? companyCode,
    String? createBy,
    String? createById,
    String? createDate,
    String? deleted,
    String? id,
    String? materialClassification,
    String? materialClassificationName,
    String? materialName,
    String? materialPhotos,
    String? materialPointId,
    String? materialPointIdName,
    String? purpose,
    int? quantity,
    String? transportationAndStorageRequirements,
    String? updateBy,
    String? updateById,
    String? updateDate,
    String? usageRecord,
    List<EmergencyResGoodsDetailUsedRecordVos>? usedRecordVos,
    String? validityPeriod,
  }) {
    return EmergencyResGoodsDetailEntity()
      ..companyCode = companyCode ?? this.companyCode
      ..createBy = createBy ?? this.createBy
      ..createById = createById ?? this.createById
      ..createDate = createDate ?? this.createDate
      ..deleted = deleted ?? this.deleted
      ..id = id ?? this.id
      ..materialClassification = materialClassification ?? this.materialClassification
      ..materialClassificationName = materialClassificationName ?? this.materialClassificationName
      ..materialName = materialName ?? this.materialName
      ..materialPhotos = materialPhotos ?? this.materialPhotos
      ..materialPointId = materialPointId ?? this.materialPointId
      ..materialPointIdName = materialPointIdName ?? this.materialPointIdName
      ..purpose = purpose ?? this.purpose
      ..quantity = quantity ?? this.quantity
      ..transportationAndStorageRequirements = transportationAndStorageRequirements ?? this.transportationAndStorageRequirements
      ..updateBy = updateBy ?? this.updateBy
      ..updateById = updateById ?? this.updateById
      ..updateDate = updateDate ?? this.updateDate
      ..usageRecord = usageRecord ?? this.usageRecord
      ..usedRecordVos = usedRecordVos ?? this.usedRecordVos
      ..validityPeriod = validityPeriod ?? this.validityPeriod;
  }
}

EmergencyResGoodsDetailUsedRecordVos $EmergencyResGoodsDetailUsedRecordVosFromJson(Map<String, dynamic> json) {
  final EmergencyResGoodsDetailUsedRecordVos emergencyResGoodsDetailUsedRecordVos = EmergencyResGoodsDetailUsedRecordVos();
  final String? date = jsonConvert.convert<String>(json['date']);
  if (date != null) {
    emergencyResGoodsDetailUsedRecordVos.date = date;
  }
  final int? num = jsonConvert.convert<int>(json['num']);
  if (num != null) {
    emergencyResGoodsDetailUsedRecordVos.num = num;
  }
  return emergencyResGoodsDetailUsedRecordVos;
}

Map<String, dynamic> $EmergencyResGoodsDetailUsedRecordVosToJson(EmergencyResGoodsDetailUsedRecordVos entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['date'] = entity.date;
  data['num'] = entity.num;
  return data;
}

extension EmergencyResGoodsDetailUsedRecordVosExtension on EmergencyResGoodsDetailUsedRecordVos {
  EmergencyResGoodsDetailUsedRecordVos copyWith({
    String? date,
    int? num,
  }) {
    return EmergencyResGoodsDetailUsedRecordVos()
      ..date = date ?? this.date
      ..num = num ?? this.num;
  }
}
